package com.zhentao.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zhentao.domain.SQuestion;
import com.zhentao.dto.ClassTuserDto;
import com.zhentao.dto.QuestionDto;
import com.zhentao.mapper.SLevelMapper;
import com.zhentao.result.Result;
import com.zhentao.service.SQuestionService;
import com.zhentao.mapper.SQuestionMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
* @author ww
* @description 针对表【s_question】的数据库操作Service实现
* @createDate 2024-07-23 10:02:26
*/
@Service
public class SQuestionServiceImpl extends ServiceImpl<SQuestionMapper, SQuestion>
    implements SQuestionService{
@Resource
private SQuestionMapper sQuestionMapper;
@Resource
   private SLevelMapper sLevelMapper;
    @Override
    public Result findAllQuestion(QuestionDto questionDto) {
        PageHelper.startPage(questionDto.getPageNum(), questionDto.getPageSize());
        List<SQuestion> allQuestion = sQuestionMapper.findAllQuestion(questionDto);
        PageInfo<SQuestion> sQuestionPageInfo = new PageInfo<>(allQuestion);
        return Result.OK(sQuestionPageInfo);
    }

    @Override
    public List<ClassTuserDto> findTeacherSubject(ClassTuserDto classTuserDto) {
        return sLevelMapper.findTeacherSubject(classTuserDto);
    }

    @Override
    public List<SQuestion> findAllQuestions(QuestionDto questionDto) {
        return sQuestionMapper.findAllQuestion(questionDto);
    }

    @Override
    public List<SQuestion> findOneError(QuestionDto questionDto) {
        return sQuestionMapper.findOneError(questionDto);
    }

    @Override
    public List<SQuestion> findAllError(Integer uid) {
        return sQuestionMapper.findAllError(uid);
    }
    @Override
    public List<SQuestion> getModel() {
        List<SQuestion> list = new ArrayList<>();
        SQuestion sQuestion1 = new SQuestion();
        sQuestion1.setQuestion("选择题模板/A.选项_B.选项_C.选项_D.选项");
        sQuestion1.setAnswerTxt("A");
        sQuestion1.setTypeId(1);

        SQuestion sQuestion2 = new SQuestion();
        sQuestion1.setQuestion("多选题模板/A.选项_B.选项_C.选项_D.选项");
        sQuestion2.setAnswerTxt("ABCD");
        sQuestion2.setTypeId(2);

        SQuestion sQuestion3 = new SQuestion();
        sQuestion3.setQuestion("判断题模板");
        sQuestion3.setAnswerTxt("正确");
        sQuestion3.setTypeId(3);

        SQuestion sQuestion4 = new SQuestion();
        sQuestion4.setQuestion("简答题模板");
        sQuestion4.setAnswerTxt("简答题答案(注: 简答题答案最好为最终答案关键字)");
        sQuestion4.setTypeId(4);
        list.add(sQuestion1);
        list.add(sQuestion2);
        list.add(sQuestion3);
        list.add(sQuestion4);
        return list;
    }
}




